import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
  isLoading: false,
  direction: 'forward',
  count: 0,
  checkInfo: [],
  activeInfo: {}
}

// 创建一个对象存储一系列我们接下来要写的 mutation 函数
const mutations = {
  // mutation 的第一个参数是当前的 state
  // 你可以在函数里修改 state
  INCREMENT (state, amount) {
    state.count = state.count + amount
  },
  DECREMENT (state, amount) {
    state.count = state.count - amount
  },
  UPDATE_LOADING (state, status) {
    state.isLoading = status
  },
  UPDATE_DIRECTION (state, direction) {
    state.direction = direction
  },
  UPDATE_CHECKINFO (state) {
    const stepinfo = {}
    state.checkInfo.push(stepinfo)
    state.activeInfo = stepinfo
  },
  SET_STEPINFO (state, step) {
    state.activeInfo = step
  }
}

export default new Vuex.Store({
  state,
  mutations
})
